﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.Json;

namespace LowCoding.Common
{
    public static class ConfigHelper//帮助程序员读取和管理配置文件的工具类,更方便地获取配置文件中的数据，从而提高程序的可维护性和可扩展性
    {
        public static IConfiguration Configuration { get; set; }

        static ConfigHelper()
        {
            //ReloadOnChange = true 当appsettings.json被修改时重新加载
            Configuration = new ConfigurationBuilder()
            .Add(new JsonConfigurationSource { Path = "appsettings.json", ReloadOnChange = true })
            //根据环境变量读取配置
            //Add(new JsonConfigurationSource { Path = $"appsettings.{System.Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}.json", ReloadOnChange = true })
            .Build();
        }
    }
}